import random


def maopao(l, x):
    for j in range(1, len(l)):
        for i in range(0, len(l)-j):
            if x > 0:
                if l[i] > l[i+1]:
                    l[i], l[i+1] = l[i+1], l[i]
            if x < 0:
                if l[i] < l[i+1]:
                    l[i], l[i+1] = l[i+1], l[i]
    return l


if __name__ == '__main__':
    lst = []
    for i in range(100):
        lst.append(random.randint(0, 100))
    s = maopao(lst, 1)     # 负值 降序, 正值 升序
    print(s)
